package com.ikangtai.shecare.common.baseView.guide;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

public class ViewPagerAdapter extends PagerAdapter{

    //界面列表
    private List<View> views;

    public ViewPagerAdapter (List<View> views){
        this.views = views;
    }

    //获得当前界面数
    @Override
    public int getCount() {
        return views != null ? views.size() : 0;
    }

    //初始化position位置的界面
    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(views.get(position), 0);
        return views.get(position);
    }

    //销毁position位置的界面
    @Override
    public void destroyItem(ViewGroup container, int position, Object object)   {
        container.removeView(views.get(position));//删除页卡
    }

    //判断是否由对象生成界面
    @Override
    public boolean isViewFromObject(View arg0, Object arg1) {
        return (arg0 == arg1);
    }
}

